<script>
function setFocus(){
	$('identity').focus()
}

function box_message(titleMessage,message){
	box_message = new LightFace({ 
			title: titleMessage, 
			width : 300,
			content: "<div class='message'>"+message+"</div>"
			,
			buttons: [{ title: 'Close', event: function() { this.close();}, color: 'green'}]
		});
		box_message.open();	
}

function resetForm(){
//	$('identity').set('value','');
//	$('name').set('value','');
//	$('place_of_birth').set('value','');
//	$('birthday').set('value','');
//	$('education').set('value','');
//	$('work').set('value','');
//	$('email').set('value','');
//	$('website').set('value','');
//	$('phone').set('value','');
//	$('address').set('value','');
//	$('city').set('value','');
//	$('achievment').set('value','');
//	$('radio').set('checked','unchecked');
}

function news_save(form, evt){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('just4u','news_save'))?>',
			method :'post',
		 	onSuccess: function(responseText, responseXML){	
			 	resetForm();	
				box_message("Confirmation","Data has been save");
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				var message = "Failed to save";
				failure(message);
			}
		});
		form.send();
	return false;
}

window.addEvent('load', function(){
		
		$('description').mooEditable({
		actions: 'bold italic underline strikethrough | formatBlock justifyleft justifyright justifycenter justifyfull | insertunorderedlist insertorderedlist indent outdent insertHorizontalRule | undo redo removeformat | createlink unlink | urlimage | toggleview'
		});
		
	//setFocus();
        new FormCheck('news_add', {
		display : {
			errorsLocation : 1,
			showErrors : 1,
			addClassErrorToField : 1
		}
	})
});

</script>
<style type="text/css">
	#description{
		width: 700px;
		height: 200px;
		padding: 10px;
		border: 2px solid #ddd;
			}
</style>
<form name="news_add" id="news_add" method="post" enctype="multipart/form-data" action="<?php echo site_url(array('just4u','news_save'))?>">
  <table width="0%" border="0" cellspacing="2" cellpadding="3">
    <tr>
      <th align="right">Name</th>
      <td><input name="name" type="text" id="name" size="35" maxlength="100" class="validate['required']" />
      <input name="author" type="hidden" id="author" value="author" /></td>
    </tr>
    <tr>
      <th align="right">Images</th>
      <td><label for="images"></label>
      <input type="file" name="images" id="images" /></td>
    </tr>
    <tr>
      <th align="right" valign="top"><p>Description</p>
        <p>&nbsp;</p></th>
      <td><textarea name="description" id="description" cols="45" rows="6" class="validate['required']"></textarea></td>
    </tr>
    <tr>
      <th align="right" valign="top">&nbsp;</th>
      <td align="right"><input type="reset" name="button2" id="button2" value="Reset" class="uiButtonRounded" />
        <input type="submit" name="button" id="button" value="Save" class="uiButtonRounded" /></td>
    </tr>
  </table>
</form>